<template>
  <div class="components-overview">
    <div class="overview-header">
      <h2 class="overview-title">前端组件概览</h2>
      <p class="overview-description">
        展示项目中可复用的前端组件，包括文件上传、表单控件、数据展示等各类组件
      </p>
      <p class="overview-subtitle">
        选择一个组件查看详细示例和文档
      </p>
    </div>

    <div class="component-grid">
      <!-- 文件上传组件 -->
      <div
        class="component-card"
        @click="navigateToComponent('file-upload-demo')"
      >
        <div class="card-header">
          <div class="card-icon">
            <upload-outlined />
          </div>
          <div class="card-status">
            <a-tag color="success">已完成</a-tag>
          </div>
        </div>
        <div class="card-body">
          <h3 class="card-title">文件上传组件</h3>
          <p class="card-description">
            包含基础文件上传和简洁卡片上传两个组件，支持拖拽、多文件、预览等功能
          </p>
          <div class="card-features">
            <span class="feature-tag">拖拽上传</span>
            <span class="feature-tag">多文件支持</span>
            <span class="feature-tag">文件预览</span>
            <span class="feature-tag">类型限制</span>
          </div>
        </div>
        <div class="card-footer">
          <span class="component-count">2个组件</span>
          <right-outlined class="arrow-icon" />
        </div>
      </div>

      <!-- 表单组件 -->
      <div
        class="component-card"
        @click="navigateToComponent('form-demo')"
      >
        <div class="card-header">
          <div class="card-icon">
            <form-outlined />
          </div>
          <div class="card-status">
            <a-tag color="success">已完成</a-tag>
          </div>
        </div>
        <div class="card-body">
          <h3 class="card-title">表单组件</h3>
          <p class="card-description">
            丰富的表单控件组件集合，包括输入框、选择器、日期选择、表单验证等功能
          </p>
          <div class="card-features">
            <span class="feature-tag">基础表单</span>
            <span class="feature-tag">高级表单</span>
            <span class="feature-tag">表单验证</span>
            <span class="feature-tag">动态表单</span>
          </div>
        </div>
        <div class="card-footer">
          <span class="component-count">3个组件</span>
          <right-outlined class="arrow-icon" />
        </div>
      </div>

      <div
        class="component-card"
        @click="navigateToComponent('data-display-demo')"
      >
        <div class="card-header">
          <div class="card-icon">
            <table-outlined />
          </div>
          <div class="card-status">
            <a-tag color="success">已完成</a-tag>
          </div>
        </div>
        <div class="card-body">
          <h3 class="card-title">数据展示组件</h3>
          <p class="card-description">
            表格、图表、统计卡片等数据可视化组件，支持多种图表类型和交互功能
          </p>
          <div class="card-features">
            <span class="feature-tag">统计卡片</span>
            <span class="feature-tag">数据表格</span>
            <span class="feature-tag">图表展示</span>
            <span class="feature-tag">仪表盘</span>
          </div>
        </div>
        <div class="card-footer">
          <span class="component-count">3个组件</span>
          <right-outlined class="arrow-icon" />
        </div>
      </div>

      <!-- 交互组件 -->
      <div
        class="component-card"
        @click="navigateToComponent('interaction-demo')"
      >
        <div class="card-header">
          <div class="card-icon">
            <interaction-outlined />
          </div>
          <div class="card-status">
            <a-tag color="success">已完成</a-tag>
          </div>
        </div>
        <div class="card-body">
          <h3 class="card-title">交互组件</h3>
          <p class="card-description">
            弹窗、抽屉、通知等用户交互组件，提供丰富的交互体验和反馈机制
          </p>
          <div class="card-features">
            <span class="feature-tag">弹窗组件</span>
            <span class="feature-tag">抽屉组件</span>
            <span class="feature-tag">通知组件</span>
            <span class="feature-tag">加载状态</span>
          </div>
        </div>
        <div class="card-footer">
          <span class="component-count">3个组件</span>
          <right-outlined class="arrow-icon" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import {
  UploadOutlined,
  RightOutlined,
  FormOutlined,
  TableOutlined,
  InteractionOutlined
} from '@ant-design/icons-vue'

const router = useRouter()

// 导航到指定组件
const navigateToComponent = (componentPath: string) => {
  router.push(`/frontend-components/${componentPath}`)
}
</script>

<style scoped>
.components-overview {
  max-width: 1200px;
  margin: 0 auto;
}

.overview-header {
  text-align: center;
  margin-bottom: 40px;
}

.overview-title {
  font-size: 28px;
  font-weight: 600;
  color: #262626;
  margin: 0 0 12px 0;
}

.overview-description {
  font-size: 16px;
  color: #595959;
  margin: 0 0 8px 0;
  line-height: 1.6;
  font-weight: 500;
}

.overview-subtitle {
  font-size: 14px;
  color: #8c8c8c;
  margin: 0;
  line-height: 1.6;
}

.component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 24px;
}

/* 组件卡片 */
.component-card {
  background: white;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  padding: 24px;
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.component-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  border-color: #1890ff;
}

.component-card--placeholder {
  opacity: 0.6;
  cursor: default;
}

.component-card--placeholder:hover {
  transform: none;
  box-shadow: none;
  border-color: #e8e8e8;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.card-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1890ff, #52c41a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
}

.card-icon--placeholder {
  background: #d9d9d9;
}

.card-body {
  flex: 1;
  margin-bottom: 20px;
}

.card-title {
  font-size: 20px;
  font-weight: 600;
  color: #262626;
  margin: 0 0 12px 0;
}

.card-description {
  font-size: 14px;
  color: #8c8c8c;
  line-height: 1.6;
  margin: 0 0 16px 0;
}

.card-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feature-tag {
  background: #f0f8ff;
  color: #1890ff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.component-count {
  font-size: 14px;
  color: #8c8c8c;
  font-weight: 500;
}

.arrow-icon {
  font-size: 16px;
  color: #bfbfbf;
  transition: all 0.3s ease;
}

.component-card:hover .arrow-icon {
  color: #1890ff;
  transform: translateX(4px);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .overview-header {
    margin-bottom: 24px;
  }

  .overview-title {
    font-size: 24px;
  }

  .overview-description {
    font-size: 14px;
  }

  .component-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .component-card {
    padding: 20px;
  }
}

/* 动画效果 */
.component-card {
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
</style>